package com.example.xch.scanzxing;

import java.io.IOException;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class HttpPost {
    public String httpPostWithToken(String url, String text){
        String result=null;
        try {
            OkHttpClient client = new OkHttpClient();
            Request request = new Request.Builder()
//                    .addHeader("token",token)
                    .url(url)
                    .post(RequestBody.create(MediaType.parse("application/json"),text))
                    .build();
            Response response = client.newCall(request).execute();
            result = response.body().string();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }
}
